event (sol)
https://softwaremill.com/images/uploads/2017/08/ethereum/decentralized-scheduling-architecture.b3fbf6af.png
SoftwareMill blog: Event sourcing on blockchain with Ethereum, TypeScript and React
Blockchain ブロックチェーンで何かが生じたときに、contract コントラクトがアプリのフロントエンドに伝えることができる
contract コントラクト外のシステムがcontract コントラクトで発生した処理を認識するために必要
event で宣言
emit で発火
'listening'状態 接続待ち
例外処理 exception handling
code:event.sol
// イベントの宣言
event IntegersAdded(uint x, uint y, uint result);
function add(uint _x, uint _y) public {
uint result = _x + _y;
// 関数が呼ばれたことをアプリに伝えるためにイベントを発生させる:
emit IntegersAdded(_x, _y, result);
return result;
}
code:event.js
YourContract.IntegersAdded(function(error, result) {
// 結果について何らかの処理をする
}